package client.authentication

import traits.JsGenerator
import org.jscala._
import models.Profesor
import vos.LoginCredentials
import models.Jornada
import models.users.Role

object AuthApp extends JsGenerator("public/authentication/auth-apppp2.js") {

  val js = javascript {
    window.define(Array("ng", "common/js/user-module", "common/js/util-module", "ui.router"),
      (angular: JsDynamic) => {
        var app = angular.module("AuthApp", Array("UserModule", "UtilModule",
          "ui.router"));

        app.config(($stateProvider: JsDynamic, $urlRouterProvider: JsDynamic) => {

          $stateProvider.state("supadmin", new {
            val url = "/supadmin";
            val controller = ($scope: JsDynamic, epModal: JsDynamic) => {

              var loginInfo = $scope.$parent.loginInfo.asInstanceOf[LoginCredentials];
              loginInfo.role = Role.valueOf("SUPADMIN");

              epModal.open("login");

            }
          });
        });
        app.controller("AuthCtrl",
          ($scope: JsDynamic, User: JsDynamic, $window: JsDynamic, $parse: JsDynamic, $http: JsDynamic, epModal: JsDynamic) => {
            $scope.roles = Array("COORDINADOR", "SECRETARIO", "PROFESOR",
              "ACUDIENTE");
            User.getCalificacionesPeriodo(new {
              var idMateria = 1l
              var idCurso = 1l
            })
            $scope.loginInfo = new {};
            $scope.logIn = () => {

            }

          });
      });
  }

  def generate = js.asString;

}
